package com.droidlogic.setupwizard.fragment;

import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;


import androidx.annotation.NonNull;
import androidx.leanback.app.GuidedStepSupportFragment;
import androidx.leanback.widget.GuidanceStylist;
import androidx.leanback.widget.GuidedAction;

import com.droidlogic.setupwizard.R;

import java.util.List;

public class WelcomeFragment extends BaseGuideStepFragment{
    private final int ID_WELCOME = 5;
    @Override
    String getNextActionLabel() {
        return getString(R.string.action_next);
    }

    @Override
    public void onNextAction() {
        GuidedStepSupportFragment.add(getParentFragmentManager(), new LocalFragment());
    }

    @Override
    public GuidanceStylist.Guidance onCreateGuidance(Bundle savedInstanceState) {
//        String title = "欢迎使用";
//        String desc = "请完成初始化设置以开始体验";
//        Drawable icon = getActivity().getDrawable(R.drawable.welcome);
//        return new GuidanceStylist.Guidance(title, desc, "向导步骤", icon);
        String title = getString(R.string.welcome_title);
        String breadcrumb = "";
        String description = getString(R.string.welcome_title_description);
        Drawable icon = getActivity().getDrawable(R.drawable.welcome);
        return new GuidanceStylist.Guidance(title, description, breadcrumb, icon);
    }
    @Override
    public void onCreateActions(@NonNull List<GuidedAction> actions, Bundle savedInstanceState) {
        if (getContext() == null) return;
        GuidedAction guidedAction = new GuidedAction.Builder(getActivity())
                .id(ID_WELCOME)
                .title(R.string.welcome_action)
                .description(R.string.welcome_description)
                .infoOnly(true)
                .build();

        actions.add(guidedAction);
    }

    @Override
    public int onProvideTheme() {
        return super.onProvideTheme();
    }

    //    @NonNull
//    @Override
//    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
//        // 创建自定义布局
//        View root = inflater.inflate(R.layout.fragment_welcome,  container, false);
//
//        // 设置右侧提示文本
//        TextView tvTips = root.findViewById(R.id.operation_tips);
//        tvTips.setText(" 操作提示：\n1. 按方向键导航\n2. 确认键选择\n3. 返回键退出");
//
//        return root;
//    }

//    @Override
//    public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
//        super.onViewCreated(view,  savedInstanceState);
//
//        // 设置右侧提示内容
//        TextView hintView = view.findViewById(R.id.operation_hint);
//        hintView.setText(" 操作提示：\n1. 使用方向键导航\n2. 按确认键继续\n3. 返回键退出");
//    }

//    @Override
//    public GuidanceStylist onCreateGuidanceStylist() {
//        return new CustomGuidanceStylist();
//    }
//
//    private static class CustomGuidanceStylist extends GuidanceStylist {
//        @Override
//        public int onProvideLayoutId() {
//            return R.layout.fragment_welcome;
//        }
//    }
}
